--- a/tools/zipdir/zipdir.c
+++ b/tools/zipdir/zipdir.c
@@ -781,6 +781,8 @@
			if (central_dir == NULL)
			{
				fprintf(stderr, "Could not read central directory from %s. (Is it a zipfile?)\n", zipname);
+				fclose(ozip);
+				ozip = NULL;
				update = 0;
			}
		}
